package Demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-21
 * Time: 14:11
 */
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        Shape sp[]=new Shape[n];
        String name;
        for(int i=0;i<n;i++) {
            name=scan.next();
            if(name.equalsIgnoreCase("rect"))
                sp[i]=new Rectangle(scan.nextInt(),scan.nextInt());
            if(name.equalsIgnoreCase("cir"))
                sp[i]=new Circle(scan.nextDouble());
            System.out.println(sp[i]);
        }
        System.out.println("总面积为："+Sum.sumAllArea(sp));
        System.out.println("总周长为："+Sum.sumAllPerimeter(sp));
    }
}

/* 请在这里填写答案 */
abstract class Shape{
    public static double PI = 3.14;
    abstract public double getPerimeter();
    abstract public double getArea();
}
class Rectangle extends Shape{
    public int width;
    public int length;

    public Rectangle(int width, int length) {
        this.width = width;
        this.length = length;
    }

    @Override
    public double getPerimeter() {
        return 2*(width+length);
    }

    @Override
    public double getArea() {
        return width*length;
    }

    @Override
    public String toString() {
        return "Rectangle [" +
                "width=" + width +
                ", length=" + length +
                ", area="+getArea()+
                ", perimeter="+getPerimeter()+
                "]";
    }
}
class Circle extends Shape{
    public double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double getPerimeter() {
        return 2*radius*PI;
    }

    @Override
    public double getArea() {
        return PI*radius*radius;
    }
    public String toString() {
        return "Circle [" +
                "radius=" + radius +
                ", area="+getArea()+
                ", perimeter="+getPerimeter()+
                "]";
    }
}
class Sum{
    static double sumAllArea(Shape s[]){
        double sum = 0;
        for (int i = 0; i < s.length; i++) {
            sum += s[i].getArea();
        }
        return sum;
    }
    static double sumAllPerimeter(Shape s[]){
        double sum = 0;
        for (int i = 0; i < s.length; i++) {
            sum += s[i].getPerimeter();
        }
        return sum;
    }
}